{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 机器读心术之神经网络与深度学习第4课书面作业\n",
    "\n",
    "学号：207567\n",
    "\n",
    "**书面作业：**\n",
    "\n",
    "1. 韩力群书第124页例6.1所示的由三个神经元组成的网络，设计权值与阈值，使其以101,000作为吸引子，并画出像图6.3那样的状态演变示意图（注意标识箭头）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**答：**  \n",
    "吸引子为$\\mathbf{x}^a=[1,0,1]^T$和$\\mathbf{x}^b=[0,0,0]^T$。  \n",
    "权值：$W_{i,j} \\in [-1,1]$, 阈值：$T_i \\in [-1,1], i,j = 1,2,3$  \n",
    "同时，$W_{i,j} = W_{j,i}$, $W_{i,i}=0$\n",
    "由吸引子$\\mathbf{X}$定义：  \n",
    "$$\n",
    "\\mathbf{f(WX)=X} \\tag{1}\n",
    "$$\n",
    "这里取的激活函数$\\mathbf{f=sgn}$，即符号函数，自变量>0时，取1，自变量<=0时，取0。  \n",
    "因此可得：\n",
    "$$\n",
    "\\left\\{ \n",
    "\\begin{array}{l}\\tag{2}\n",
    "    W_{1,1}\\times 1+W_{1,2}\\times 0+W_{1,3}\\times 1 - T_1 =W_{1,3}-T_1 > 0 \\\\ \n",
    "    W_{2,1}\\times 1+W_{2,2}\\times 0+W_{2,3}\\times 1 - T_2 =W_{2,1}+W_{2,3}-T_2 < 0 \\\\\n",
    "    W_{3,1}\\times 1+W_{3,2}\\times 0+W_{3,3}\\times 1 - T_3 =W_{3,1}-T_3 > 0\n",
    "\\end{array}\n",
    "\\right. \n",
    "$$\n",
    "针对上面的方程对于<0取-1，>0取1，则整理后得到：\n",
    "$$\n",
    "\\left\\{ \n",
    "\\begin{array}{l}\\tag{3}\n",
    "    W_{1,3}-T_1 =1 \\\\ \n",
    "    W_{2,1}+W_{2,3}-T_2 =-1 \\\\\n",
    "    W_{3,1}-T_3 =1\n",
    "\\end{array}\n",
    "\\right. \n",
    "$$\n",
    "再考虑第2个吸引子，可得：\n",
    "$$\n",
    "\\left\\{ \n",
    "\\begin{array}{l} \\tag{4}\n",
    "    W_{1,1}\\times 0+W_{1,2}\\times 0+W_{1,3}\\times 0 - T_1 =T_1 = 0 \\\\ \n",
    "    W_{2,1}\\times 0+W_{2,2}\\times 0+W_{2,3}\\times 0 - T_2 =T_2 = 0 \\\\\n",
    "    W_{3,1}\\times 0+W_{3,2}\\times 0+W_{3,3}\\times 0 - T_3 =T_3 = 0\n",
    "\\end{array}\n",
    "\\right. \n",
    "$$\n",
    "式(4)表明所有阈值为0，同时(4)和(3)结合，可得：\n",
    "$$\n",
    "\\left\\{ \n",
    "\\begin{array}{l}\\tag{5}\n",
    "    W_{1,3}=W_{3,1} =1 \\\\ \n",
    "    W_{2,1}+W_{2,3} =-1 \\\\\n",
    "\\end{array}\n",
    "\\right. \n",
    "$$\n",
    "我在这里任取一组解：\n",
    "$$\n",
    "\\left\\{ \n",
    "\\begin{array}{l}\\tag{5}\n",
    "    W_{1,3}=W_{3,1} =1 \\\\ \n",
    "    W_{1,2}=W_{2,1}=-0.5 \\\\\n",
    "    W_{2,3}=W_{3,2} =-0.5 \\\\\n",
    "\\end{array}\n",
    "\\right. \n",
    "$$\n",
    "因此我们得到如下的DHNN："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```mermaid\n",
    "graph LR\n",
    "    A1[node1:0] ---|0.5| A2[node2:0]\n",
    "    A1[node1:0] ---|-1| A3[node3:0]\n",
    "    A2[node2:0] ---|0.5| A3[node3:0]\n",
    "   \n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "fb9f349487484364a76a86d689de2291b320d01c749a280950eb5136d479374c"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
